<?php if(!empty($pager)): ?>
    <?php if(empty($currentPage)): ?>
        <?php $currentPage = $pager->currentPage; ?>
    <?php endif; ?>
    <?php $pageSize = $pager->pageSize; ?>
    <?php $page_count = ceil($pager->itemCount/$pageSize); ?>
    <div class="pagenation">
        <ul>
            <li class="back <?php if ($currentPage == 0) echo 'disabled' ?>">
                <?php if ($currentPage > 0): ?>
                    <a data-page="<?php echo $currentPage ?>" href="<?php echo $this->createPageUrl($currentPage - 1) ?>" >上一页</a>
                <?php endif; ?>
            </li>

            <?php if($page_count > 1 && $page_count < 9): ?>
                <!-- 显示8页  小于9页时 -->
                <?php for ($i = 1; $i <= $page_count; $i++) :?>
                    <?php if($i - 1 == $currentPage): ?>
                        <!-- 当前页 -->
                        <li><a class="current"><?php echo $i ?></a></li>
                    <?php else: ?>
                        <li>
                            <a data-page="<?php echo $i ?>" href="<?php echo $this->createPageUrl($i - 1) ?>" ><?php echo $i ?></a>
                        </li>
                    <?php endif; ?>
                <?php endfor; ?>
            <?php elseif ($page_count > 1): ?>
                <!-- 大于等于9页 -->
                <li>
                    <?php if ($currentPage > 0): ?>
                        <a data-page="1" href="<?php echo $this->createPageUrl(0) ?>" >1</a>
                    <?php else: ?>
                        <a data-page="1" class="current" >1</a>
                    <?php endif; ?>
                </li>
                <?php if ($page_count >= 9 && $currentPage > 4): ?>
                    <li><span class="dot">...</span></li>
                <?php endif; ?>

                <?php for ($i = 2; $i < $page_count; $i++) :?>
                    <?php if($currentPage < 5 && $i < 9): ?>
                        <?php if($i - 1 == $currentPage): ?>
                            <li><a class="current"><?php echo $i ?></a></li>
                        <?php else: ?>
                            <li><a data-page="<?php echo $i ?>" href="<?php echo $this->createPageUrl($i - 1) ?>" ><?php echo $i ?></a></li>
                        <?php endif; ?>
                    <?php elseif ($page_count - 7 < $currentPage && $page_count - 7 < $i): ?>
                        <?php if($i - 1 == $currentPage): ?>
                            <li><a class="current"><?php echo $i ?></a></li>
                        <?php else: ?>
                            <li><a data-page="<?php echo $i ?>" href="<?php echo $this->createPageUrl($i - 1) ?>" ><?php echo $i ?></a></li>
                        <?php endif; ?>
                    <?php else: ?>
                        <?php if($i - 1 > $currentPage - 3 && $i - 1 < $currentPage + 4): ?>
                            <?php if($i - 1 == $currentPage): ?>
                                <li><a class="current"><?php echo $i ?></a></li>
                            <?php else: ?>
                                <li><a data-page="<?php echo $i ?>" href="<?php echo $this->createPageUrl($i - 1) ?>" ><?php echo $i ?></a></li>
                            <?php endif; ?>
                        <?php endif; ?>
                    <?php endif; ?>
                <?php endfor; ?>
                <?php if ($page_count >= 9 && $page_count - $currentPage > 5 && $page_count - 7 >= $currentPage): ?>
                    <li><span class="dot">...</span></li>
                <?php endif; ?>
                <li>
                    <?php if ($currentPage + 1 != $page_count): ?>
                        <a data-page="<?php echo $page_count ?>" href="<?php echo $this->createPageUrl($page_count - 1) ?>" ><?php echo $page_count ?></a>
                    <?php else: ?>
                        <a data-page="<?php echo $page_count ?>" class="current"><?php echo $page_count ?></a>
                    <?php endif; ?>
                </li>
            <?php elseif ($page_count == 1): ?>
                <li><a class="current">1</a></li>
            <?php endif; ?>

            <?php if($currentPage + 1 < $page_count): ?>
                <li class="next"><a data-page="<?php echo $currentPage + 2 ?>" href="<?php echo $this->createPageUrl($currentPage + 1) ?>" >下一页</a></li>
            <?php endif; ?>
            <li><span class="total">共<?php echo $page_count ?>页</span></li>
            <li class="drump"><span>跳转至</span><input type="number" class="drump_inp">页</li>
        </ul>
    </div>
<?php endif; ?>
<script type="text/javascript">
    $('.page a').click(function(){
        $('.page_input').val($(this).data('page'));
        $('.search_form').submit();
        return false;
    });
</script>


<?php if (false): ?>


<!-- 分页 -->
                    <div class="pagenation">
                        <ul>
                            <li class="back disabled"><a>上一页</a></li>
                            <li><a class="current">1</a></li>
                            <li><a>2</a></li>
                            <li><a>3</a></li>
                            <li><a>4</a></li>
                            <li><a>5</a></li>
                            <li><a>6</a></li>
                            <li><a>7</a></li>
                            <li><a>8</a></li>
                            <li><span class="dot">...</span></li>
                            <li class="next"><a>下一页</a></li>
                            <li><span class="total">共50页</span></li>
                            <li class="drump">跳转至<input type="number" class="drump_inp">页</li>
                        </ul>
                    </div>
<?php endif; ?>